goog.provide('mitel.request');

mitel.request.makeRequest = function(url, onSuccess, onFailure) {
  var params = {};
  params[gadgets.io.RequestParameters.CONTENT_TYPE] = gadgets.io.ContentType.JSON;
  params[gadgets.io.RequestParameters.AUTHORIZATION] = gadgets.io.AuthorizationType.OAUTH;
  params[gadgets.io.RequestParameters.OAUTH_SERVICE_NAME] = 'google';
  params[gadgets.io.RequestParameters.OAUTH_USE_TOKEN] = 'always';
  params[gadgets.io.RequestParameters.METHOD] = gadgets.io.MethodType.GET;

  gadgets.io.makeRequest(url, function(response) {
    if (response.oauthApprovalUrl) {
      onFailure(response);
    } else {
      onSuccess(response);
    }
  }, params);
};
